﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace deviceManage.Models
{
    public partial class DeviceCtx : DbContext
    {
        public DeviceCtx()
        {
        }

        public DeviceCtx(DbContextOptions<DeviceCtx> options)
            : base(options)
        {
        }

        public virtual DbSet<DevicePlanItem> DevicePlanItem{ get; set; }
        public virtual DbSet<DailyCheckRoom> DailyCheckRoom { get; set; }
        public virtual DbSet<DevicePlanTime> DevicePlanTime { get; set; }        
        public virtual DbSet<BuyContract> BuyContract { get; set; }
        public virtual DbSet<ContractPay> ContractPay { get; set; }
        public virtual DbSet<DailyCheck> DailyCheck { get; set; }
        public virtual DbSet<DailyCheckDevice> DailyCheckDevice { get; set; }
        public virtual DbSet<Depart> Depart { get; set; }
        public virtual DbSet<Device> Device { get; set; }
        public virtual DbSet<DeviceServiceLog> DeviceServiceLog { get; set; }
        public virtual DbSet<DevicePlan> DevicePlan { get; set; }
        public virtual DbSet<DeviceType> DeviceType { get; set; }
        public virtual DbSet<Document> Document { get; set; }
        public virtual DbSet<DocumentType> DocumentType { get; set; }
        public virtual DbSet<LendLog> LendLog { get; set; }
        public virtual DbSet<Menu> Menu { get; set; }
        public virtual DbSet<Message> Message { get; set; }
        public virtual DbSet<MoveoutLog> MoveoutLog { get; set; }
        public virtual DbSet<PlanExecuteTime> PlanExecuteTime { get; set; }
        public virtual DbSet<Project> Project { get; set; }
        public virtual DbSet<RepairLog> RepairLog { get; set; }
        public virtual DbSet<Role> Role { get; set; }
        public virtual DbSet<RoleMenu> RoleMenu { get; set; }
        public virtual DbSet<RoleUser> RoleUser { get; set; }
        public virtual DbSet<Room> Room { get; set; }
        public virtual DbSet<ScrapLog> ScrapLog { get; set; }
        public virtual DbSet<ServiceContract> ServiceContract { get; set; }
        public virtual DbSet<Supplier> Supplier { get; set; }
        public virtual DbSet<TransferLog> TransferLog { get; set; }
        public virtual DbSet<User> User { get; set; }
        public virtual DbSet<DeviceTypeCategory> DeviceTypeCategory { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {           
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<DailyCheckRoom>(entity=> {
                entity.ToTable("daily_check_room");
            });

            modelBuilder.Entity<BuyContract>(entity =>
            {
                entity.ToTable("buy_contract");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceTypeId)
                .HasColumnName("device_type_id")
                .HasColumnType("varchar(36)");



                entity.Property(e => e.Addr)
                    .HasColumnName("addr")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.Amount)
                    .HasColumnName("amount")
                    .HasColumnType("decimal(10,0)");

                entity.Property(e => e.BuyCount)
                    .HasColumnName("buy_count")
                    .HasColumnType("int(11)");

                entity.Property(e => e.BuyUser)
                    .HasColumnName("buy_user")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasMaxLength(36);

                entity.Property(e => e.EndDate)
                    .HasColumnName("end_date")
                    .HasColumnType("date");

                entity.Property(e => e.Purpose)
                    .HasColumnName("purpose")
                    .HasMaxLength(300);

                entity.Property(e => e.StartDate)
                    .HasColumnName("start_date")
                    .HasColumnType("date");

                entity.Property(e => e.Title)
                    .HasColumnName("title")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("int(11)");
            });

            modelBuilder.Entity<DevicePlanItem>(entity=> {
                entity.ToTable("device_plan_items");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.PlanId)
                    .HasColumnName("plan_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");


                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("datetime");
                
            });

            modelBuilder.Entity<DevicePlanTime>(entity => {
                entity.ToTable("device_plan_times");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.PlanYear)
                    .HasColumnName("plan_year")
                    .HasColumnType("int");

                entity.Property(e => e.PlanId)
                    .HasColumnName("plan_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.PlanMonth)
                     .HasColumnName("plan_month")
                     .HasColumnType("int");

                entity.Property(e => e.PlanDate)
                     .HasColumnName("plan_date")
                     .HasColumnType("date");


            });

            modelBuilder.Entity<ContractPay>(entity =>
            {
                entity.ToTable("contract_pay");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Amount)
                    .HasColumnName("amount")
                    .HasColumnType("decimal(10,0)");

                entity.Property(e => e.ContractId)
                    .HasColumnName("contract_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("char(10)");

                entity.Property(e => e.PayDate)
                    .HasColumnName("pay_date")
                    .HasColumnType("date");

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(36)");
            });

            modelBuilder.Entity<DailyCheck>(entity =>
            {
                entity.ToTable("daily_check");

              

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CheckDate)
                    .HasColumnName("check_date")
                    .HasColumnType("date");

                entity.Property(e => e.CheckUser)
                    .HasColumnName("check_user")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("varchar(36)");

                

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(500)");

               
            });

            modelBuilder.Entity<DailyCheckDevice>(entity =>
            {
                entity.ToTable("daily_check_device");

              

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CheckId)
                    .HasColumnName("check_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(200)"); 
                
            });

            modelBuilder.Entity<Depart>(entity =>
            {
                entity.ToTable("depart");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.SortOrder)
                    .HasColumnName("sort_order")
                    .HasColumnType("int(11)");
            });

            modelBuilder.Entity<Device>(entity =>
            {
                entity.ToTable("device");

                entity.HasIndex(e => e.BuyContractId)
                    .HasName("FK_Reference_13");
                

                entity.HasIndex(e => e.Location)
                    .HasName("FK_Reference_2");

                entity.HasIndex(e => e.ProjectId)
                    .HasName("FK_Reference_16");

                entity.HasIndex(e => e.ServiceContract)
                    .HasName("FK_Reference_14"); 

               

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.BuyContractId)
                    .HasColumnName("buy_contract_id")
                    .HasColumnType("varchar(60)");

                entity.Property(e => e.BuyDate)
                    .HasColumnName("buy_date")
                    .HasColumnType("date");

                entity.Property(e => e.DepartId)
                    .HasColumnName("depart_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceTypeId)
                    .HasColumnName("device_type")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Ip)
                    .HasColumnName("ip")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.IsDomestic)
                    .HasColumnName("is_domestic")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.Location)
                    .HasColumnName("location")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.Model)
                    .HasColumnName("model")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.No)
                    .HasColumnName("no")
                    .HasColumnType("varchar(60)");

                entity.Property(e => e.Os)
                    .HasColumnName("os")
                    .HasColumnType("varchar(60)");

                entity.Property(e => e.ProjectId)
                    .HasColumnName("project_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.ReceiveDate)
                    .HasColumnName("receive_date")
                    .HasColumnType("date");

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(500)");

                entity.Property(e => e.RoomId)
                    .HasColumnName("room_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.ServiceContract)
                    .HasColumnName("service_contract")
                    .HasColumnType("varchar(60)");

                entity.Property(e => e.ServiceDate)
                    .HasColumnName("service_date")
                    .HasColumnType("date");

                entity.Property(e => e.Status)
                    .HasColumnName("status")
                    .HasColumnType("int(11)");

                        

                entity.Property(e => e.SupplierId)
                    .HasColumnName("t_s_ID")
                    .HasColumnType("varchar(36)");

                entity.HasOne(d => d.BuyContract)
                    .WithMany(p => p.Device)
                    .HasForeignKey(d => d.BuyContractId)
                    .HasConstraintName("FK_Reference_13");
                                     

                entity.HasOne(d => d.Project)
                    .WithMany(p => p.Device)
                    .HasForeignKey(d => d.ProjectId)
                    .HasConstraintName("FK_Reference_16");

                entity.HasOne(d => d.ServiceContractNavigation)
                    .WithMany(p => p.Device)
                    .HasForeignKey(d => d.ServiceContract)
                    .HasConstraintName("FK_Reference_14");

                
                    

            });

            modelBuilder.Entity<DeviceServiceLog>(entity =>
            {
                entity.ToTable("device_service_log");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_19");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Month)
                    .HasColumnName("month")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Year)
                    .HasColumnName("year")
                    .HasColumnType("int(11)");

                entity.HasOne(d => d.Device)
                    .WithMany(p => p.DeviceServiceLog)
                    .HasForeignKey(d => d.DeviceId)
                    .HasConstraintName("FK_Reference_19");
            });

            modelBuilder.Entity<DevicePlan>(entity =>
            {
                entity.ToTable("device_service_plan");

                entity.HasIndex(e => e.ContractId)
                    .HasName("FK_Reference_26");

                entity.HasIndex(e => e.ProjectId)
                    .HasName("FK_Reference_25");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.ContractId)
                    .HasColumnName("contract_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.UserParticipate)
                    .HasColumnName("user_participate")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.EndTime)
                    .HasColumnName("end_time")
                    .HasColumnType("date");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.ProjectId)
                    .HasColumnName("project_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(1000)");

                entity.Property(e => e.StartTime)
                    .HasColumnName("start_time")
                    .HasColumnType("date");

                entity.Property(e => e.User)
                    .HasColumnName("user")
                    .HasColumnType("varchar(100)"); 
            });

            modelBuilder.Entity<DeviceType>(entity =>
            {
                entity.ToTable("device_type");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.SortOrder)
                    .HasColumnName("sort_order")
                    .HasColumnType("int(11)");

                entity.Property(e =>e.DeviceTypeCategoryId)
                    .HasColumnName("category_id")
                    .HasColumnType("varchar(36)");
                
            });

            modelBuilder.Entity<Document>(entity =>
            {
                entity.ToTable("document");

                entity.HasIndex(e => e.TypeId)
                    .HasName("FK_Reference_20");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Category)
                    .HasColumnName("category")
                    .HasColumnType("int(11)");

                entity.Property(e=>e.FilePath)
                    .HasColumnName("file_path")
                    .HasColumnType("varchar(300)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(150)");

                entity.Property(e => e.ObjectId)
                    .HasColumnName("object_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.TypeId)
                    .HasColumnName("type_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.UploadTime)
                    .HasColumnName("upload_time")
                    .HasColumnType("date");

                entity.Property(e => e.UploadUser)
                    .HasColumnName("upload_user")
                    .HasColumnType("varchar(36)");

              
            });

            modelBuilder.Entity<DocumentType>(entity =>
            {
                entity.ToTable("document_type");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(60)");
            });

            modelBuilder.Entity<LendLog>(entity =>
            {
                entity.ToTable("lend_log");

                entity.HasIndex(e => e.DepartId)
                    .HasName("FK_Reference_6");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_5");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DepartId)
                    .HasColumnName("depart_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DepartName)
                    .HasColumnName("depart_name")
                    .HasColumnType("varchar(150)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.LendDate)
                    .HasColumnName("lend_date")
                    .HasColumnType("date");

                entity.Property(e => e.LendDuration)
                    .HasColumnName("lend_duration")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Reason)
                    .HasColumnName("reason")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.ReturnDate)
                    .HasColumnName("return_date")
                    .HasColumnType("date");

                entity.Property(e => e.ReturnUser)
                    .HasColumnName("return_user")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasColumnType("int(11)");

               
                
            });

            modelBuilder.Entity<Menu>(entity =>
            {
                entity.ToTable("menu");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Icon)
                    .HasColumnName("icon")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.Level)
                    .HasColumnName("level")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(60)");

                entity.Property(e => e.ParentId)
                    .HasColumnName("parent_id")
                    .HasMaxLength(36);

                entity.Property(e => e.Url)
                    .HasColumnName("url")
                    .HasMaxLength(200);
            });

            modelBuilder.Entity<Message>(entity =>
            {
                entity.ToTable("message");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Content)
                    .HasColumnName("content")
                    .HasColumnType("varchar(300)");

                entity.Property(e => e.ReadTime)
                    .HasColumnName("read_time")
                    .HasColumnType("date");

                entity.Property(e => e.ReadUser)
                    .HasColumnName("read_user")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Readed)
                    .HasColumnName("readed")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Title)
                    .HasColumnName("title")
                    .HasColumnType("varchar(150)");

                entity.Property(e => e.Type)
                    .HasColumnName("type")
                    .HasColumnType("int(11)");
            });

            modelBuilder.Entity<MoveoutLog>(entity =>
            {
                entity.ToTable("moveout_log");

                entity.HasIndex(e => e.DepartId)
                    .HasName("FK_Reference_9");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_10");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DepartId)
                    .HasColumnName("depart_ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DepartName)
                    .HasColumnName("depart_name")
                    .HasColumnType("varchar(150)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Reason)
                    .HasColumnName("reason")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.TransferDate)
                    .HasColumnName("transfer_date")
                    .HasColumnType("date");

                

                entity.HasOne(d => d.Device)
                    .WithMany(p => p.MoveoutLog)
                    .HasForeignKey(d => d.DeviceId)
                    .HasConstraintName("FK_Reference_10");
            });

            modelBuilder.Entity<PlanExecuteTime>(entity =>
            {
                entity.ToTable("plan_execute_time");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_18");

                entity.HasIndex(e => e.PlanId)
                    .HasName("FK_Reference_17");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Month)
                    .HasColumnName("month")
                    .HasColumnType("int(11)");

                entity.Property(e => e.PlanId)
                    .HasColumnName("plan_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Year)
                    .HasColumnName("year")
                    .HasColumnType("int(11)");

                entity.HasOne(d => d.Device)
                    .WithMany(p => p.PlanExecuteTime)
                    .HasForeignKey(d => d.DeviceId)
                    .HasConstraintName("FK_Reference_18");

                entity.HasOne(d => d.Plan)
                    .WithMany(p => p.PlanExecuteTime)
                    .HasForeignKey(d => d.PlanId)
                    .HasConstraintName("FK_Reference_17");
            });

            modelBuilder.Entity<Project>(entity =>
            {
                entity.ToTable("project");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.UseUnit)
                    .HasColumnName("use_unit")
                    .HasColumnType("varchar(60)");
                                               
                entity.Property(e => e.Amount)
                    .HasColumnName("amount")
                    .HasColumnType("decimal(10,0)");

                entity.Property(e => e.ContractId)
                    .HasColumnName("contract_id")
                    .HasMaxLength(36);

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.DevelopUnit)
                    .HasColumnName("develop_unit")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.Finish)
                    .HasColumnName("finish")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.FinishDate)
                    .HasColumnName("finish_date")
                    .HasColumnType("date");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.Participate)
                    .HasColumnName("participate")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.SortOrder)
                    .HasColumnName("sort_order")
                    .HasColumnType("int(11)");

                entity.Property(e => e.StartTime)
                    .HasColumnName("start_time")
                    .HasColumnType("date");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasColumnType("int(11)");


                entity.Property(e => e.DepartId)
                    .HasColumnName("depart_id")
                    .HasColumnType("varchar(36)");

            });

            modelBuilder.Entity<RepairLog>(entity =>
            {
                entity.ToTable("repair_log");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_12");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.BeginDate)
                    .HasColumnName("begin_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("int(11)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.EndDate)
                    .HasColumnName("end_date")
                    .HasColumnType("date");

                entity.Property(e => e.Remark)
                    .HasColumnName("remark")
                    .HasColumnType("varchar(500)");

                entity.Property(e => e.State)
                    .HasColumnName("state")
                    .HasColumnType("int(11)");

                
            });

            modelBuilder.Entity<Role>(entity =>
            {
                entity.ToTable("role");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.RoleName)
                    .HasColumnName("role_name")
                    .HasColumnType("varchar(60)");
            });

            modelBuilder.Entity<RoleMenu>(entity =>
            {
                entity.ToTable("role_menu");

                entity.HasIndex(e => e.MenId)
                    .HasName("FK_Reference_24");

                entity.HasIndex(e => e.RoleId)
                    .HasName("FK_Reference_23");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.MenId)
                    .HasColumnName("men_ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.RoleId)
                    .HasColumnName("role_id")
                    .HasColumnType("varchar(60)");

                entity.HasOne(d => d.Men)
                    .WithMany(p => p.RoleMenu)
                    .HasForeignKey(d => d.MenId)
                    .HasConstraintName("FK_Reference_24");

                entity.HasOne(d => d.Role)
                    .WithMany(p => p.RoleMenu)
                    .HasForeignKey(d => d.RoleId)
                    .HasConstraintName("FK_Reference_23");
            });

            modelBuilder.Entity<RoleUser>(entity =>
            {
                entity.ToTable("role_user");

                entity.HasIndex(e => e.RoleId)
                    .HasName("FK_Reference_22");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.RoleId)
                    .HasColumnName("role_id")
                    .HasColumnType("varchar(60)");

                entity.Property(e => e.UserId)
                    .HasColumnName("user_id")
                    .HasMaxLength(36);

                entity.HasOne(d => d.Role)
                    .WithMany(p => p.RoleUser)
                    .HasForeignKey(d => d.RoleId)
                    .HasConstraintName("FK_Reference_22");
            });

            modelBuilder.Entity<Room>(entity =>
            {
                entity.ToTable("room");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.SortOrder)
                    .HasColumnName("sort_order")
                    .HasColumnType("int(11)");
            });

            modelBuilder.Entity<ScrapLog>(entity =>
            {
                entity.ToTable("scrap_log");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_7");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Reason1)
                    .HasColumnName("reason1")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.ScrapDate)
                    .HasColumnName("scrap_date")
                    .HasColumnType("date");

                entity.HasOne(d => d.Device)
                    .WithMany(p => p.ScrapLog)
                    .HasForeignKey(d => d.DeviceId)
                    .HasConstraintName("FK_Reference_7");
            });

            modelBuilder.Entity<ServiceContract>(entity =>
            {
                entity.ToTable("service_contract");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DeviceTypeId)
                    .HasColumnName("device_type_id")
                    .HasColumnType("varchar(36)");

                

                entity.Property(e => e.Addr)
                    .HasColumnName("addr")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.Amount)
                    .HasColumnName("amount")
                    .HasColumnType("decimal(10,0)");

                entity.Property(e => e.Boss)
                    .HasColumnName("boss")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasMaxLength(36);

                entity.Property(e => e.DonePercent)
                    .HasColumnName("done_percent")
                    .HasColumnType("decimal(10,0)");

                entity.Property(e => e.Employee)
                    .HasColumnName("employee")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.EndDate)
                    .HasColumnName("end_date")
                    .HasColumnType("date");

                entity.Property(e => e.SendUsers)
                    .HasColumnName("send_users")
                    .HasMaxLength(300);

                entity.Property(e => e.ServiceCountLimit)
                    .HasColumnName("service_count_limit")
                    .HasColumnType("int(11)");

                entity.Property(e => e.StartDate)
                    .HasColumnName("start_date")
                    .HasColumnType("date");

                entity.Property(e => e.Title)
                    .HasColumnName("title")
                    .HasColumnType("varchar(200)");

            });

            modelBuilder.Entity<Supplier>(entity =>
            {
                entity.ToTable("supplier");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Deleted)
                    .HasColumnName("deleted")
                    .HasColumnType("tinyint(1)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.SortOrder)
                    .HasColumnName("sort_order")
                    .HasColumnType("int(11)");
            });

            modelBuilder.Entity<TransferLog>(entity =>
            {
                entity.ToTable("transfer_log");

                entity.HasIndex(e => e.DepartId)
                    .HasName("FK_Reference_8");

                entity.HasIndex(e => e.DeviceId)
                    .HasName("FK_Reference_11");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.CreateDate)
                    .HasColumnName("create_date")
                    .HasColumnType("date");

                entity.Property(e => e.CreateUserId)
                    .HasColumnName("create_user_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DepartId)
                    .HasColumnName("depart_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.DepartName)
                    .HasColumnName("depart_name")
                    .HasColumnType("varchar(150)");

                entity.Property(e => e.DeviceId)
                    .HasColumnName("device_id")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Reason)
                    .HasColumnName("reason")
                    .HasColumnType("varchar(200)");

                entity.Property(e => e.TransferDate)
                    .HasColumnName("transfer_date")
                    .HasColumnType("date");
 

                entity.HasOne(d => d.Device)
                    .WithMany(p => p.TransferLog)
                    .HasForeignKey(d => d.DeviceId)
                    .HasConstraintName("FK_Reference_11");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.ToTable("user");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasColumnType("varchar(36)");

                entity.Property(e => e.Cellphone)
                    .HasColumnName("cellphone")
                    .HasColumnType("varchar(11)");

                entity.Property(e => e.Email)
                    .HasColumnName("email")
                    .HasColumnType("varchar(100)");

                entity.Property(e => e.LoginName)
                    .HasColumnName("login_name")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.Pass)
                    .HasColumnName("pass")
                    .HasMaxLength(50);


                entity.Property(e => e.DepartId)
                    .HasColumnName("depart_id")
                    .HasColumnType("varchar(36)");

            });

            modelBuilder.Entity<DeviceTypeCategory>(entity =>
            {
                entity.ToTable("device_type_category");

                entity.Property(e => e.SortOrder)
                    .HasColumnName("sort_order")
                    .HasColumnType("int");
            });
                
        }
    }
}
